use sea_orm_migration::{prelude::*, schema::*};

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        // Replace the sample below with your own migration scripts
        // todo!();

        manager
            .create_table(
                Table::create()
                    .table("sys_user")
                    .if_not_exists()
                    .col(pk_auto("id"))
                    .col(string("username"))
                    .col(string("gender"))
                    .col(string("account"))
                    .col(string("password"))
                    .col(string("mobile_phone"))
                    .col(boolean("enabled"))
                    .col(timestamp_with_time_zone("created_at"))
                    .col(timestamp_with_time_zone_null("updated_at"))
                    .col(timestamp_with_time_zone_null("deleted_at"))
                    .to_owned(),
            )
            .await
            
    }

    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        // Replace the sample below with your own migration scripts
        // todo!();

        manager
            .drop_table(Table::drop().table("post").to_owned())
            .await
    }
}
